package gui.secondary;

import java.awt.Color;
import java.net.URL;

import javax.swing.JLabel;
import javax.swing.JScrollPane;

import tool.CustomizedButton;

import controller.gui.CancelButtonController;
import controller.gui.SelectionBoxController;
import controller.gui.maplayermenu.MapLayerConceptBrowseController;
import controller.gui.maplayermenu.MapLayerOKController;
import controller.gui.maplayermenu.MapLayerRendererBrowseController;

import gui.DescribedCustomizedButton;
import gui.SelectionBox;
import gui.SecondaryMenu;
import gui.TextPanel;

/** Il SecondaryMenu dedicato ad ospitare le opzioni
 *  riguardanti i MapLayers.
 * @author Daniele
 * @version 1.5 */
public class MapLayerSecondaryMenu extends SecondaryMenu {

	private static final long serialVersionUID = 7562578225114644030L;
	
	// Scritte e info dei pulsanti in questo SecondaryMenu.
	private static final String TXT_BROWSE_CONCEPT = "Browse Concepts";
	private static final String TXT_BROWSE_RENDERER = "Browse Renderers";
	private static final URL DESC_BROWSE_CONCEPT = MapLayerSecondaryMenu.class.getResource("BrowseBkConceptsDESC.html");
	private static final URL DESC_BROWSE_RENDERER = MapLayerSecondaryMenu.class.getResource("BrowseBkRenderersDESC.html");
	
	/** La scritta contenuta nell'etichetta associata al riquadro dei concepts. */
	private static final String CONCEPTS_LABEL = "Available MapLayer Concepts:";
	/** La scritta contenuta nell'etichetta associata al riquadro dei renderers. */
	private static final String RENDERER_LABEL = "Available MapLayers Renderers:";

	/** L'etichetta che introduce il riquadro dei MapLayerConcepts. */
	private JLabel conceptLabel;
	/** Il riquadro entro il quale mostrare i vari tipi di MapLayerConcepts. */
	private SelectionBox chooseConceptWindow;
	/** L'etichetta che introduce il riquadro dei MapLayerRenderers. */
	private JLabel rendererLabel;
	/** Il riquadro entro il quale mostrare i vari tipi di Renderers possibili. */
	private SelectionBox chooseRendererWindow;
	/** Il pulsante che permette di sfogliare i files dei concepts. */
	private CustomizedButton browseConceptButton;
	/** Il pulsante che permette di sfogliare i files dei renderers. */
	private CustomizedButton browseRendererButton;
	

	//TODO un giorno tutte le classi grafiche che richiedono addLIsteners implementaranno un'interfaccia contenente tale metodo... ricordarsi che dovranno throws NullPointerException in caso un controller sia null!
	
//	public void addListeners(MapLayerOKController ok,CancelButtonController cancel,MapLayerConceptBrowseController conceptbrowse,MapLayerRendererBrowseController rendererbrowse,SelectionBoxController chooserconcept,SelectionBoxController chooserrenderer) throws NullPointerException{
//		
//		//*************************** cablaggio OK/Cancel Button ************************
//		ok.wire(this.okButton, this);
//		cancel.wire(this.cancelButton,this);
//		//*************************** cablaggio BrowseButton ****************************
//		conceptbrowse.wire(browseConceptButton);
//		rendererbrowse.wire(this.browseRendererButton);
//		//*************************** cablaggio SelectionBox ****************************
//		chooserconcept.wire(chooseConceptWindow);
//		chooserrenderer.wire(chooseRendererWindow);
//		//*************************** cablaggio tra i controller *************************
//		conceptbrowse.wire(chooserconcept);
//		rendererbrowse.wire(chooserrenderer);
//	}
	
	/** Costruisce il SecondaryMenu contenente le opzioni
	 *  relative ai MapLayers. */
	public MapLayerSecondaryMenu(){
		
		super();
		
		descriptionLabel = new TextPanel();
		descriptionLabel.loadContent(MapLayerSecondaryMenu.class.getResource("MapLayersDESC.html"));
		this.initializeJScrollPane();
		this.addComponentToLayout(descriptionLabelScrollPane, 0, 0, 2.5, 10, 0, 2);
		
		conceptLabel = new JLabel(CONCEPTS_LABEL);
		this.addComponentToLayout(conceptLabel, 0, 1, 0.5, 0, 0, 2);
		
		chooseConceptWindow = new SelectionBox();
		JScrollPane scrollConceptPane = new JScrollPane(this.chooseConceptWindow, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		this.addComponentToLayout(scrollConceptPane, 0, 2, 2, 0, 0, 2);
		
		this.browseConceptButton = new DescribedCustomizedButton(MapLayerSecondaryMenu.TXT_BROWSE_CONCEPT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,MapLayerSecondaryMenu.DESC_BROWSE_CONCEPT);
		this.addComponentToLayout(browseConceptButton, 0, 3, 0.5, 10, 0, 2);
		this.browseConceptButton.addMouseListener(descriptionLabel);
		
		rendererLabel = new JLabel(RENDERER_LABEL);
		this.addComponentToLayout(rendererLabel, 0, 4, 0.5, 0, 0, 2);
		
		chooseRendererWindow = new SelectionBox();
		JScrollPane scrollRendererPane = new JScrollPane(this.chooseRendererWindow, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		this.addComponentToLayout(scrollRendererPane, 0, 5, 2, 0, 0, 2);
		
		this.browseRendererButton = new DescribedCustomizedButton(MapLayerSecondaryMenu.TXT_BROWSE_RENDERER,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,MapLayerSecondaryMenu.DESC_BROWSE_RENDERER);
		this.addComponentToLayout(browseRendererButton, 0, 6, 0.5, 10, 0, 2);
		this.browseRendererButton.addMouseListener(descriptionLabel);
		
		this.addToMapButton = new DescribedCustomizedButton(SecondaryMenu.TXT_ADD,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,SecondaryMenu.DESC_ADD);
		this.addComponentToLayout(addToMapButton, 0, 7, 0.5, 10, 0, 2);
		this.addToMapButton.addMouseListener(descriptionLabel);
		
		this.okButton = new DescribedCustomizedButton(SecondaryMenu.TXT_OK,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,SecondaryMenu.DESC_OK);
		this.addComponentToLayout(okButton, 0, 8, 0.5, 10, 10, 1);
		this.okButton.addMouseListener(descriptionLabel);
		
		this.cancelButton = new DescribedCustomizedButton(SecondaryMenu.TXT_CANCEL,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN,SecondaryMenu.DESC_CANCEL);
		this.addComponentToLayout(cancelButton, 1, 8, 0.5, 10, 10, 1);
		this.cancelButton.addMouseListener(descriptionLabel);
	}

	/** Getter per il riquadro di scelta dei concepts.
	 * @return the chooseConceptWindow. For further information visit {@link #chooseConceptWindow} */
	public SelectionBox getChooseConceptWindow() {
		return chooseConceptWindow;
	}

	/** Getter per il riquadro di scelta del renderer.
	 * @return the chooseRendererWindow. For further information visit {@link #chooseRendererWindow} */
	public SelectionBox getChooseRendererWindow() {
		return chooseRendererWindow;
	}
	
	/** Getter per l'etichetta che precede il riquadro dei Concepts.
	 * @return the conceptLabel */
	public JLabel getConceptLabel() {
		return conceptLabel;
	}

	/** Getter per l'etichetta che precede il riquadro dei Renderers.
	 * @return the rendererLabel */
	public JLabel getRendererLabel() {
		return rendererLabel;
	}

	/** Getter per il pulsante che sfoglia tra i Concepts.
	 * @return the browseConceptButton. For further information visit {@link #browseConceptButton}*/
	public CustomizedButton getBrowseConceptButton() {
		return browseConceptButton;
	}
	
	/** Getter per il pulsante che sfoglia tra i Renderers.
	 * @return the browseRendererButton. For further information visit {@link #browseRendererButton} */
	public CustomizedButton getBrowseRendererButton() {
		return browseRendererButton;
	}
}
